package com.sparsearr.datastructures.itheima.payplan;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Scanner;

/**
 * @Author: ZhaoTR
 * @Date: Created in 2025/4/19 15:51
 * @Description: 买飞机票
 * @Version: 1.0
 */

public class BuyPlane {
    private static final Logger logger = LogManager.getLogger(BuyPlane.class);

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入机票的原价");
        int ticket = scanner.nextInt();
        System.out.println("请输入当前的月份");
        int month = scanner.nextInt();
        System.out.println("请输入当前购买的仓位是 0 头等舱 1 经济舱");
        int seat = scanner.nextInt();
        if (month >= 5 && month <= 10) {
            // 旺季
            ticket = getPrice(ticket, seat, 0.9, 0.85);
        } else if ((month >= 1 && month <= 4) || (month >= 11 && month <= 12)) {
            // 淡季
            ticket = getPrice(ticket, seat, 0.7, 0.65);
        } else {
            System.out.println("月份输入有误");
        }
        System.out.println(ticket);
    }

    public static int getPrice(int ticket, int seat, double v0, double v1) {
        if (seat == 0) {
            ticket = (int) (ticket * v0);
        } else if (seat == 1) {
            ticket = (int) (ticket * v1);
        } else {
            System.out.println("仓位输入有误");
        }
        return ticket;
    }
}
